<?php
// 这是系统自动生成的dynamic应用公共文件
/**
 * 去掉友好时间的雷达时间
 */

if ( !function_exists( 'lbHandelRadarDateNo' ) )
{
    function lbHandelRadarDateNo ( $data, $field = 'create_time' )
    {
        //  今天的时间戳
        $time = time();
        //  昨天的时间戳
        $Yesterday = $time - ( 24 * 60 * 60 );

        $today     = mktime( 0, 0, 0, date( "m", $time ), date( "d", $time ), date( "Y", $time ) );
        $Yesterday = mktime( 0, 0, 0, date( "m", $Yesterday ), date( "d", $Yesterday ), date( "Y", $Yesterday ) );

        foreach ( $data as $index => $item )
        {
            $tmpTime = $item[ $field ];
            if ( $tmpTime > $today&&$tmpTime<time())
            {
                //                $data[ $index ][ 'radar_time' ] = '今天 ';
                $data[ $index ][ 'radar_group' ] = '今天';
                $data[ $index ][ 'radar_time' ]  = date( 'H:i', $item[ $field ] );
            }
            else if ( $tmpTime > $Yesterday&&$tmpTime<time() )
            {
                //                $data[ $index ][ 'radar_time' ] = '昨天 ';
                $data[ $index ][ 'radar_group' ] = '昨天';
                $data[ $index ][ 'radar_time' ]  = date( 'H:i', $item[ $field ] );
            }
            else
            {
                $thisYear = date( 'Y' );
                $itemYear = date( 'Y', $item[ $field ] );
                if ( $thisYear == $itemYear )
                {
                    $data[ $index ][ 'radar_group' ] = date( 'm-d', $item[ $field ] );
                    $data[ $index ][ 'radar_time' ]  = date( ' H:i', $item[ $field ] );
                }
                else
                {
                    $data[ $index ][ 'radar_group' ] = date( 'Y-m-d', $item[ $field ] );
                    $data[ $index ][ 'radar_time' ]  = date( ' H:i', $item[ $field ] );
                }

            }
        }
        return $data;
    }
}